﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using SeniorCapstoneProject.ServiceReference3;

namespace SeniorCapstoneProject
{
    public partial class frmCreateUser : Form
    {
        public frmCreateUser()
        {
            InitializeComponent();
        }

        private void frmCreateUser_Load(object sender, EventArgs e)
        {
            Thread.Sleep(500);
            try
            {
                TransferFilesClient tfc = new TransferFilesClient();
                var gList = tfc.GetGroups();

                if (gList.Count() > 0)
                {
                    foreach (ServiceReference3.HelperClass hc in gList)
                    {
                        HelperClass hcl = new HelperClass();
                        hcl.GroupID = hc.GroupID;
                        hcl.GroupName = hc.GroupName;

                        cbxGroups.Items.Add(hcl.GroupName);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

        }

        private void btnCreateUser_Click(object sender, EventArgs e)
        {

            
            string password = txtPassword.Text;
            
            string hash = Convert.ToBase64String(System.Security.Cryptography.MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(password))
);
            MessageBox.Show("Username:" + txtUserName.Text +  "Hashed Password:" + hash);
            /*TransferFilesClient tfc = new TransferFilesClient();

            HelperClass.newUser newUser = new HelperClass.newUser(txtUserName.Text, txtPassword.Text, cbxGroups.SelectedItem);

            newUser.UserName = txtUserName.Text;
            newUser.PassHash = txtPassword.Text;
            newUser.UserGroup = cbxGroups.SelectedItem.ToString();*/
            

            

            
            /*login ClientLogin = new login(txtUsername.Text, txtPassword.Text, this);
            Thread StartClientLogin = new Thread(new ThreadStart(ClientLogin.clientLogin));
            StartClientLogin.Name = "ClientLogin";
            StartClientLogin.IsBackground = true;
            StartClientLogin.Start(); //Start thread
            this.ClientLogin = ClientLogin;*/
        }

        
    }
}
